<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="newtemplatesfiles5/img/favicon.html">

    <title>电动车登记</title>

    <!-- Bootstrap core CSS -->
    <link href="newtemplatesfiles5/css/bootstrap.min.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="newtemplatesfiles5/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="newtemplatesfiles5/css/style.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="newtemplatesfiles5/js/html5shiv.js"></script>
    <script src="newtemplatesfiles5/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<section id="container" class="">
    <!--header start-->
    <div th:insert="common/student-common-header::top"></div>
    <!--header end-->
    <!--sidebar start-->
    <div th:insert="common/student-common-sidebar::#left"></div>
    <!--sidebar end-->
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
            <!-- page start-->
            <div class="row">
                <!--student-info-left  start-->
                <div th:insert="common/student-info-left::#student-info-left"></div>
                <!--student-info-left  end-->
                <aside class="profile-info col-lg-9">
                    <section class="panel">
                        <div class="bio-graph-heading">
                            <h2>电动车登记</h2>
                        </div>
                        <div class="panel-body">
                            <form role="form" id="ebickForm">
                                <div class="form-group">
                                    <label for="exampleInputEmail1">电动车品牌</label>
                                    <input id="exampleInputEmail1" name="brand" type="text" class="form-control" placeholder="品牌">
                                </div>
                                <div class="form-group">
                                    <label>卖方商家和地址</label>
                                    <input name="buyfrom" type="text" class="form-control" placeholder="省/市/店名">
                                </div>
                                <div class="form-group">
                                    <label>备注</label>
                                    <input name="Details" type="text" class="form-control" placeholder="备注">
                                </div>
                                <div class="form-group">
                                    <label>照片: (最大不超过10M)</label>
                                    <img style="width: 120px" id="show" src="" alt="请上传图片"><br>
                                    <input  type="file" id="myfile" name="image"  onchange="showImage()">
                                </div>
                            </form>
                            <button type="submit" class="btn btn-info" onclick="ebickSubmit()">登记</button>
                        </div>
                    </section>
                </aside>
            </div>
            <script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
            <script type="text/javascript" src="js/jquery.min.js"></script>
            <script src="asserts/js/popper.min.js"></script>
            <script src="asserts/js/feather.min.js"></script>
            <script src="asserts/js/bootstrap.min.js"></script>
            <script type="text/javascript">
                //图片回显
                function showImage() {
                    var reader = new FileReader();
                    var file = document.getElementById("myfile").files[0];
                    console.log(file);
                    reader.onload=function (e) {
                        ///console.log(this.result);
                        document.getElementById('show').src=this.result;
                        //alert(this.result);
                    };
                    reader.readAsDataURL(file);
                }


                function verifyLoginStatus() {
                    //验证登录状态
                    console.log("1");
                    var message = document.getElementById("mystatus").innerText;
                    console.log(message);
                    if(message == '请先登录'){
                        alert("请登录");
                        location.href="login";
                        return '1';
                    }
                    return '2';
                }

                //表单提交
                function ebickSubmit() {

                    var status = verifyLoginStatus();

                    if(status == '2'){
                        var form = new FormData(document.getElementById("ebickForm"));
                        $.ajax({
                            url:"ebickRegist.do",
                            type:"post",
                            dataType:"html",
                            data:form,
                            cache:false,
                            processData:false,
                            contentType:false,
                            success: function (data) {
                                console.log("success");
                                alert("登记成功！去申请行驶证吧。");
                                location.href="getAllMyEbicks.do";

                            },
                            error:function (data) {
                                console.log("error");
                            }
                        })
                    }

                }



            </script>
            <!-- page end-->
        </section>
    </section>
    <!--main content end-->
</section>

<!-- js placed at the end of the document so the pages load faster -->
<script src="newtemplatesfiles5/js/jquery.js"></script>
<script src="newtemplatesfiles5/js/bootstrap.min.js"></script>
<script src="newtemplatesfiles5/js/jquery.scrollTo.min.js"></script>
<script src="newtemplatesfiles5/js/jquery.nicescroll.js" type="text/javascript"></script>
<script src="newtemplatesfiles5/assets/jquery-knob/js/jquery.knob.js"></script>

<!--common script for all pages-->
<script src="newtemplatesfiles5/js/common-scripts.js"></script>

<script>

    window.onload=function(){
            $("#li1").removeClass('active');
            $("#li2").removeClass('active');
            $("#li3").removeClass('active');
            $("#li4").addClass('active');
            $("#li5").removeClass('active');
            $("#li6").removeClass('active');
            $("#li7").removeClass('active');
    };
    //knob
    $(".knob").knob();

</script>


</body>
</html>
